import axios from 'axios'

const HOST = 'http://120.48.21.41';



export async function check(success, fail, login) {
    if (localStorage.getItem('username') === undefined) {
        alert('未登陆或信息已失效');
        fail();
        return
    }
     await axios.get(HOST + `/method/check?username=${localStorage.getItem('username')}`).then((res) => {
        switch (res.data) {
            case 'code=3\n': {
                success();
                break;
            }
            case 'code=4\n': {
                alert('登陆信息已失效,请重新登录');
                fail();
                break;
            }
            default: {
                fail();
                alert('未知错误');
                break;
            }
        }
    }).catch((err) => {
        console.log(err);
    });

}



export default HOST;